<template>
<div>
<el-card class="box-card">
<div slot="header" class="clearfix">
    <span>商城配置</span>
</div>	
<el-tabs type="card">

  	<el-tab-pane label="首页管理">
  		<el-tabs>
		    <el-tab-pane label="轮播图" >
		    	<toppic 
		    	v-if="info.id != undefined" v-bind:configInfo="info" ></toppic>
		    </el-tab-pane>
		    <el-tab-pane label="商城简介" >
		    	<describe 
		    	v-if="info.id != undefined" v-bind:configInfo="info" ></describe>
		    </el-tab-pane>
		    <el-tab-pane label="产品分类" >
		    	<configtype 
		    	v-if="info.id != undefined" v-bind:configInfo="info" ></configtype>
		    </el-tab-pane>
		    <el-tab-pane label="商城栏目" >
		    	<configcolumn 
		    	v-if="info.id != undefined" v-bind:configInfo="info"  >
		    	</configcolumn>
		    </el-tab-pane>
	  	</el-tabs>
	</el-tab-pane>

	<el-tab-pane label="商城管理">
		<configuration
		v-if="info.id != undefined" v-bind:configInfo="info">
		</configuration>
	</el-tab-pane>

	<el-tab-pane label="分销体系管理">
		<el-tabs>
			<el-tab-pane label="分销体系" >
		    	<distribution >
				</distribution>
		    </el-tab-pane>
			<el-tab-pane label="分销级别" >
		    	<level >
		    	</level>
		    </el-tab-pane>
	  	</el-tabs>
	</el-tab-pane>

	<el-tab-pane label="公众号设置" v-if="ispossess">
		<weixinconfig ></weixinconfig>
	</el-tab-pane>

	
	
</el-tabs>
</el-card>
</div>		
</template>

<script>

import { mapGetters } from 'vuex'
import toppic from './children/toppic'
import describe from './children/describe'
import configtype from './children/type'
import configcolumn from './children/column'
import configuration from './children/configuration'
import distribution from './children/distribution'
import level from './children/level'
import weixinconfig from './children/weixin'

export default {
	name: 'shopconfig',
	data () {
		return {
			ispossess : false,
		  	info : {
		  	},
		}
	},

	props: {

	},

	components: {
		toppic, 
		describe, 
		configtype,
		configcolumn,
		configuration,
		distribution,
		level,
		weixinconfig,
	},

	computed : {
		...mapGetters([
			//'configInfo',
		]),

		
	},

	methods : {
		getInfo () {
			console.log('mmmmm');
			this.$store.dispatch('getConfigInfo', {
				cb : res => {
					console.log(res);
					if(res == ''){
						console.log('第一次进来。');
						let para = {
							fun : 'updateConfig',
				    		cb : res1 => {
								this.$store.dispatch('getConfigInfo', {
									cb : res1 => {
										this.info = res1;
									}
								});
							},
							err : res1 => {
								this.$notify({
						          title: '保存失败',
						          message: res1,
						          type: 'error'
						        });
							}
				    	};

				    	this.$store.dispatch('update', para)

				    	//this.$store.dispatch('updateConfig', para);
				  		//this.info = res;
					}
					else{
						this.info = res;
					}

				}
			});


		}
	},

	watch : {
	    
	},

	mounted () {
		this.getInfo();

		const para2 = {
			fun : 'userStep',
			requestType : 'get',
			cb : res => {
				console.log('333');
				console.log(res);

				//没有自己公众号
				if(res.ispossess == undefined || res.ispossess == '1'){
					this.ispossess = true;
				}
				
			}
		};

		this.$store.dispatch('update', para2);

	},

}
</script>

<style scoped>

</style>
